﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mime;

namespace Epam.PhotoGallery.Interfaces.DataTransferObjects
{
    public enum ImageStorageType { Url, Database }

    public class CommunityImage
    {
        #region Fields

        private string _imagePath;
        private ImageStorageType _storageType;
        private string _id;
        private ImageData _content;

        #endregion


        #region Constructors


        public CommunityImage(ImageStorageType storageType)
        {
            _storageType = storageType;
            _imagePath = string.Empty;

            if (!IsUrlImage)
            {
                _content=new ImageData();
            }
        }

        #endregion


        #region Properties

        public string ID
        {
            get
            {
                if (_id == null)
                {
                    _id = Guid.NewGuid().ToString();
                }

                return _id;
            }
        }


        public bool IsUrlImage
        {
            get
            {
                return _storageType == ImageStorageType.Url;
            }
        }

        public string Path
        {
            get
            {
                return _imagePath;
            }

            set
            {
                if (value != null && IsUrlImage)
                {
                    _imagePath = value;
                }
            }
        }

        public ImageData ImageData
        {
            get
            {
                return _content;
            }

        }

        #endregion
    }
}
